from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter
from meiduo_admin.home import views
from meiduo_admin.user import user_views
from meiduo_admin.good import sku_views,spu_views,spec_views,spec_options_views,sku_images_views,channel_views,brand_views
from meiduo_admin.order import order_views
from meiduo_admin.system import permission_views,group_permission_views,admin_permission_views


urlpatterns = [
    #----------------------------首页部分
    url(r'^authorizations/$', obtain_jwt_token),
    url(r'^statistical/total_count/$', views.UserTotalCountView.as_view()),
    url(r'^statistical/day_increment/$', views.UserIncrementCountView.as_view()),
    url(r'^statistical/day_active/$',views.UserDayActiveCountView.as_view()),
    url(r'^statistical/day_orders/$',views.UserDayOrderCountView.as_view()),
    url(r'^statistical/month_increment/$',views.UserMonthIncreamentCountView.as_view()),
    url(r'^statistical/goods_day_views/$',views.UserGoodsVisitCountView.as_view()),
    #----------------------------用户部分
    url(r'^users/$',user_views.UserView.as_view()),
    #----------------------------商品部分
    # url(r'^sku/$',views.SKUView.as_view(({"get":"list"})))
    #3,sku
    url(r'^skus/categories/$',sku_views.SKUCategoryView.as_view()),
    url(r'^goods/simple/$',sku_views.SKUGoodSimpleView.as_view()),
    url(r'^goods/(?P<spu_id>\d+)/specs/$',sku_views.SKUGoodsSpecsView.as_view()),
    url(r'^goods/brands/simple/$',spu_views.SPUBrandSimpleView.as_view()),
    url(r'^goods/channel/categories/$',spu_views.SPUCategoryView.as_view()),
    url(r'^goods/channel/categories/(?P<category_id>\d+)/$',spu_views.SPUCategorySubView.as_view()),
    url(r'^goods/images/$',spu_views.SPUImageUploadView.as_view()),
    url(r'^goods/specs/simple/$',spec_options_views.OptionSpecView.as_view()),
    url(r'^skus/simple/$',sku_images_views.SKUImageViewSet.as_view({"get":"simple"})),
    #8.orders   后面可以自动生成路由@方法
    # url(r'^orders/(?P<pk>\w+)/status/$',order_views.OrderViewSet.as_view({"put":"status"})),
    #9.
    url(r'^goods/channel_types/$', channel_views.ChannelTypesViewSet.as_view()),
    url(r'^goods/categories/$', channel_views.CategoriesViewSet.as_view()),
    url(r'^permission/content_types/$',permission_views.PermissionContentTypeView.as_view()),
    #10,
    url(r'^permission/simple/$', group_permission_views.PermissionSimpleView.as_view()),
    #11.
    url(r'^permission/groups/simple/$',admin_permission_views.GroupPermissionView.as_view())

]

#13,/permission/admins/
router = DefaultRouter()
router.register(r'permission/admins',admin_permission_views.AdminPermissionViewSet,base_name="admins")
urlpatterns += router.urls


#12,/permission/group/
router = DefaultRouter()
router.register(r'permission/groups',group_permission_views.GroupPermissionViewSet,base_name="groups")
urlpatterns += router.urls




#11.permission/perms/
router=DefaultRouter()
router.register(r'permission/perms',permission_views.PermissionViewSet,base_name="permission")
urlpatterns += router.urls


#10.brands
router = DefaultRouter()
router.register(r'goods/brands',brand_views.BrandsViewSet,base_name="brands")
urlpatterns += router.urls


#9.channels
# /goods/channels/(?P<pk>[^/.])
# /goods/channels/
router = DefaultRouter()
router.register(r'goods/channels',channel_views.ChannelViewSet,base_name="channel")
urlpatterns += router.urls



#8,orders
router = DefaultRouter()
router.register(r'orders',order_views.OrderViewSet,base_name="orders")
urlpatterns += router.urls


#7,/skus/images/
#7,/skus/images/(?P<pk>[^/.])
router = DefaultRouter()
router.register(r'skus/images',sku_images_views.SKUImageViewSet,base_name="images")
urlpatterns += router.urls


#6./specs/options/
router = DefaultRouter()
router.register(r'specs/options',spec_options_views.SpecOptionsViewSet,base_name="options")
urlpatterns += router.urls

#5./goods/specs/
router = DefaultRouter()
router.register(r'goods/specs',spec_views.SpecViewSet,base_name="specs")
urlpatterns += router.urls

#4,spu
router = DefaultRouter()
router.register(r'goods',spu_views.SPUViewSet,base_name="goods")
urlpatterns += router.urls

#1.创建路由
router=DefaultRouter()
#2.注册视图集
router.register(r'skus',sku_views.SKUViewSet,base_name="skus")
#3.添加路由到urlpatterns
urlpatterns += router.urls